<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- 兼容性 -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>基础设置-项目构成</title>
    <script src="/scripts/boot.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:hidden;
        }
        body{
            background: #ffffff!important;
            padding:20px;
        }
    </style>
</head>
<body>
<div class="title-list mb-20"><span class="title-listbg"></span><span>职能工作计划督导</span></div>
<div id="qForm"  class="mini-toolbar1" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <div class="mb-20 position-rel">
                    <span class="search-title search-ml20">节点名称</span><input name="nodeName" id="nodeNames"  class="mini-textbox w220"/>
                    <span class="search-title search-ml60">选择年月</span><div id="yearItem"></div>
                    <!--<span class="search-title search-ml60">选择年月</span><input id="date1" allowInput="false" class="mini-monthpicker search-200px"/>-->
                    <a class="add-botton search-ml60" onclick="list.search()">查询</a>
                    <a class="resetting-btn search-ml20" onclick="list.reset()">重置</a>
                </div>
            </td>
        </tr>
    </table>
</div>
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;"  url="/supervise/listByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="true" showEmptyText="true" emptyText="暂无数据" alwaysShowEmptyText="true">
        <div property="columns">
            <div type="indexcolumn" headerAlign="center" width="30" align="center">编号</div>
            <div field="planName" width="250" headerAlign="center" allowSort="false">计划名称</div>
<!--             <div field="businessName" width="120" headerAlign="center" align="center" allowSort="false">职能中心</div> -->
            <div field="nodeName" width="120" headerAlign="center" allowSort="false">节点名称</div>
<!--             <div field="nodePropertyName" width="120" headerAlign="center" align="center" allowSort="false">节点性质</div> -->
            <!--<div field="completeStandard" width="120" headerAlign="center" allowSort="false">完成标准</div>-->
<!--             <div field="delayNum" width="80" headerAlign="center" align="center" allowSort="false">申请延期次数</div> -->
            <div field="overDay" width="80" headerAlign="center" align="center" allowSort="false">逾期天数</div>
            <div field="riskState" width="80" headerAlign="center" align="center" allowSort="false">状态</div>
            <div field="rate" width="80" headerAlign="center" align="center" allowSort="false">进度</div>
            <div field="beginEndDate" width="120" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">计划起止时间</div>
<!--             <div field="delayDate" width="120" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd" renderer="ondayRenderer">延期到时间</div> -->
            <div field="postName" width="120" headerAlign="center" align="center" allowSort="false">负责人</div>
            <!--<div field="remark" width="120" headerAlign="center" allowSort="false">备注</div>-->
            <div name="action" width="260" headerAlign="center" align="center" allowSort="false">操作</div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //list.init();
    var grid;
    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            common.changeYears();
            grid = mini.get("datagrid1");
            grid.load({code: "100045",month:new Date().getTime()});
            mini.get("datagrid1").on("drawcell", function (e) {

                var column = e.column;
                if(column.field=="riskState"){
                    if(e.row.riskState==1){
                        e.cellHtml = '<span class="span-yellow">有风险</span>';
                    }else if(e.row.riskState==2){
                        e.cellHtml = '<span class="span-red">失控</span>';
                    }
                }
                if(column.field=="rate"){
                    e.cellHtml = e.row.rate+'%';
                }
                if(column.field=="beginEndDate"){
                    var dateText = "";
                    if(e.row.beginDate&&e.row.endDate){
                        dateText="至"
                    }
                    e.cellHtml = (e.row.beginDate?e.row.beginDate.substring(0,10):"")+dateText+(e.row.endDate?e.row.endDate.substring(0,10):"");
                }
                if (column.name == "action") {
                    e.cellHtml = '<a class="check-botton" href="javascript:list.recordList()">填报记录</a>'+
                        '<a class="check-botton btn-bd" href="javascript:list.supervisorList()">督导记录</a>'+
                        '<a class="revise-botton btn-bd" href="javascript:list.supervisor()">督导</a>' +
                        '<a class="revise-botton btn-bd" href="javascript:list.view()">计划详情</a>';
                }
            })
        },
        //计划详情
        view: function(){
            mini.open({
                url: "/planSupervision/funcPlan/view.html",
                title: "计划详情", width: 1100, height: 700,
                onload: function () {
                    var row = grid.getSelected();
                    var data = {"id": row.id};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //填报记录
        recordList: function(){
            mini.open({
                url: "/program/monthlyPlan/recordList.html",
                title: "填报记录", width: 1100, height: 700,
                onload: function () {
                    var row = grid.getSelected();
                    // var id = row.id.substr(0,row.id.lastIndexOf("@"));
                    var data = {"id": row.id};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //督导记录
        supervisorList: function(){
            mini.open({
                url: "/planSupervision/keyPoint/supervisorList.html",
                title: "督导记录", width: 1100, height: 700,
                onload: function () {
                    var row = grid.getSelected();
                    // var id = row.id.substr(0,row.id.lastIndexOf("@"));
                    var data = {"id": row.id,'nodeName':row.nodeName};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.list.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //督导
        supervisor: function(){
            mini.open({
                url: "/planSupervision/keyPoint/supervisor.html",
                title: "督导", width: 1100, height: 700,
                onload: function () {
                    var row = grid.getSelected();
                    // var id = row.id.substr(0,row.id.lastIndexOf("@"));
                    var state=row.riskState==1?"有风险":"失控";
                    var data = {"id": row.id,"nodeName":row.nodeName,'postName':row.postName,'state':state};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //    查询
        search: function () {
            var years = mini.get("year").getValue();
            var mouths = mini.get("month").getValue();
            var choseText="",getText="";
            if(mouths==""){
                var choseYear = years+'-'+'01'+'-'+'01';
                choseText = new Date(choseYear).getTime();
            }else{
                var allYear = years+'-'+mouths+'-'+'01';
                getText = new Date(allYear).getTime();
            }
            var data = {
                code: "100045",
                "nodeName": mini.get("nodeNames").getValue(),
                "year": choseText,
                "month": getText
            };
            grid.load(data);
        },

        //重置
        reset:function(){
            mini.get("year").setValue(new Date().getFullYear());
            var years = mini.get("year").getValue();
            var endMonth = new Date().getMonth()+1;
            mini.get("month").setValue(endMonth);
            var mouths = mini.get("month").getValue();
            mini.get("nodeNames").setValue("");//清空项目名称
            var allYear = years+'-'+mouths+'-'+'01';
            var getText = new Date(allYear).getTime();
            grid.load({code: "100045","month": getText})
        }
    };
    list.init();
</script>
</body>
</html>